package com.yzc.android.ui;

import android.os.Bundle;
import android.widget.TextView;

import butterknife.Bind;
import com.yzc.android.R;
import com.yzc.android.beans.UpgradeVersionBean;
import com.yzc.android.manager.UpgradeManager;
import com.yzc.android.manager.UpgradeManager.OnUpgradeListener;
import com.yzc.android.ui.base.activity.KDBaseActivity;
import com.yzc.android.utils.LogUtils;
import com.yzc.android.utils.ToastUtil;

/**
 * Created by yzc on 15/9/16.
 */
public class UpgradeActivity extends KDBaseActivity implements OnUpgradeListener {
    public @Bind(R.id.first_tv_description)
    TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        UpgradeManager.getInstance().unregisterListener(this);
    }

    @Override
    protected void setupView(final Bundle savedInstanceState) {
        mNavigationBar.setTitle("Android Rapid");
        mTextView.setText("changed");
        UpgradeManager.getInstance().registerListener(this);
        UpgradeVersionBean bean = new UpgradeVersionBean();
        bean.packageUrl = "http://d.edaijia.cn/customer/edaijia_v7.3.0.apk";
        bean.up_status = UpgradeManager.kIsForceUpgrade;
        //UpgradeManager.getInstance().handleVersionBean(bean);
    }

    @Override
    public int getLayout() {
        return R.layout.layout_activity_first;
    }

    @Override
    public void pullToRefreshHandler() {

    }

    @Override
    public void onUpgradeDownloadStart(final UpgradeVersionBean versionBean) {
        LogUtils.d("onUpgradeDownloadStart");
        ToastUtil.getInstance().showToast("onUpgradeDownloadStart");
    }

    @Override
    public void onUpgradeDownloadPause(final UpgradeVersionBean versionBean) {
        LogUtils.d("onUpgradeDownloadPause");
        ToastUtil.getInstance().showToast("onUpgradeDownloadPause");
    }

    @Override
    public void onUpgradeDownloadComplete(final UpgradeVersionBean versionBean) {
        LogUtils.d("onUpgradeDownloadComplete");
        ToastUtil.getInstance().showToast("onUpgradeDownloadComplete");
    }

    @Override
    public void onUpgradeDownloadFailed(final UpgradeVersionBean versionBean) {
        LogUtils.d("onUpgradeDownloadFailed");
        ToastUtil.getInstance().showToast("onUpgradeDownloadFailed");
    }

    @Override
    public void onUpgradeDownloadProgress(final UpgradeVersionBean versionBean,
                                          final long progressSize,
                                          final long totalSize) {
        LogUtils.d("onUpgradeDownloadProgress:%s/%s", progressSize, totalSize);
    }
}
